package com.intramirror.product.algorithm.impl;

import com.intramirror.product.entity.Product;
import com.intramirror.product.entity.Spu;
import com.intramirror.product.entity.SpuInexactProduct;
import com.intramirror.product.mapper.AggregateMapper;
import com.intramirror.product.service.ISpuService;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created on 2018/1/31.
 * @author 123
 */
public class BaseAggregateAlgorithm {
    @Autowired
    AggregateMapper aggregateMapper;

    @Autowired
    private ISpuService spuService;

    protected String replaceWithPattern(String src, String pattern, String dest) {
        return src.replaceAll(pattern, dest);
    }

    protected Spu exactMatchWithExistsSpu(Product product) {
        return spuService.exactMatchWithExistsSpu(product);
    }

    protected void inexactMatchWithExistsSpu(Product product) {
        return;
        //        List<Spu> inexactSpuList = spuService.inexactMatchWithExistsSpu(product);
        //        if (inexactSpuList != null && inexactSpuList.size() > 0) {
        //            String uuid = UUID.randomUUID().toString();
        //            for (Spu inexactSpu : inexactSpuList) {
        //                SpuInexactProduct spuInexactProduct = new SpuInexactProduct();
        //                spuInexactProduct.setMatchId(uuid);
        //                spuInexactProduct.setProductId(product.getProductId());
        //                spuInexactProduct.setProductDesignerId(product.getDesignerId());
        //                spuInexactProduct.setProductColorCode(product.getColorCode());
        //                spuInexactProduct.setSpuId(inexactSpu.getSpuId());
        //                spuInexactProduct.setSpuDesignerId(inexactSpu.getDesignerId());
        //                spuInexactProduct.setSpuColorCode(inexactSpu.getColorCode());
        //                aggregateMapper.insertSpuInexactProduct(spuInexactProduct);
        //            }
        //        }
    }
}
